/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package com.yuecai.modules.yc_gift_good.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.List;

/**
* @website https://el-admin.vip
* @description /
* @author dm
* @date 2020-10-26
**/
@Entity
@Data
@Table(name="yc_gift")
public class YcGift implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    @ApiModelProperty(value = "id")
    private Integer id;

    @Column(name = "lower_limit",nullable = false)
    @NotNull(message = "订单价格下限不能为空")
    @ApiModelProperty(value = "订单价格下限")
    private BigDecimal lowerLimit;

    @Column(name = "upper_limit",nullable = false)
    @NotNull(message = "订单价格上限不能为空")
    @ApiModelProperty(value = "订单价格上限")
    private BigDecimal upperLimit;

    @Column(name = "create_time")
    @ApiModelProperty(value = "时间")
    private Timestamp createTime;

    @OneToMany(mappedBy = "giftId",cascade={CascadeType.PERSIST,CascadeType.REMOVE})
    private List<YcGiftGood> ycGiftGoodList;

    public void copy(YcGift source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}